package pack0713;

public class Test5 {
    public static void main(String[] args) {
        new Thread(()->{
            for (int i = 0; i < 30; i++) {
                System.out.println(Thread.currentThread().getName()+":"+i);
                Thread.yield();
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"线程1").start();

        new Thread(()->{
            for (int i = 0; i <30 ; i++) {
                System.out.println(Thread.currentThread().getName()+":"+i);
                Thread.yield();
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"线程2").start();
    }
}
